package com.xyoto.community.controller;

import com.xyoto.community.dto.AddRotationChartDTO;
import com.xyoto.community.dto.UpdateRotationChartDTO;
import com.xyoto.community.service.RotationChartService;
import com.xyoto.community.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author coderFu
 * @create 2021/11/17
 */
@RestController
@Api(tags = "轮播图模块")
@RequestMapping("/rotationChart")
public class RotationChartController {

    @Autowired
    public RotationChartService rotationChartService;

    @ApiOperation("添加轮播图")
    @PostMapping("/addRotationChart")
    public Result addRotationChart(@Valid AddRotationChartDTO addRotationChartDTO){
        return rotationChartService.addRotationChart(addRotationChartDTO);
    }

    @ApiOperation("更新轮播图")
    @PutMapping("/updateRotationChart")
    public Result updateRotationChart(@Valid UpdateRotationChartDTO updateRotationChartDTO){
        return rotationChartService.updateRotationChart(updateRotationChartDTO);
    }

    @ApiOperation("查询轮播图列表")
    @GetMapping("/getRotationChartList")
    public Result getRotationChartList(){
        return rotationChartService.getRotationChartList();
    }

    @ApiOperation("根据轮播图id获取轮播图详情")
    @GetMapping("/getRotationChartDetailsById")
    public Result getRotationChartDetailsById(@RequestParam("id") Integer id){
        return rotationChartService.getRotationChartDetailsById(id);
    }


}
